home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / fastmath / vb5sampl.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-04-05  |  15.7 KB  |  534 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "UCALC Fast Math Parser 1.0"
  4.    ClientHeight    =   5280
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   7785
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   5280
  10.    ScaleWidth      =   7785
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command1 
  13.       Caption         =   "Start"
  14.       Height          =   375
  15.       Left            =   3840
  16.       TabIndex        =   34
  17.       Top             =   4440
  18.       Width           =   495
  19.    End
  20.    Begin VB.TextBox Text10 
  21.       Height          =   285
  22.       Left            =   5760
  23.       TabIndex        =   31
  24.       Top             =   4920
  25.       Width           =   1935
  26.    End
  27.    Begin VB.TextBox Text8 
  28.       Height          =   285
  29.       Left            =   5760
  30.       TabIndex        =   30
  31.       Text            =   "x^2+5x-10"
  32.       Top             =   4560
  33.       Width           =   1935
  34.    End
  35.    Begin VB.TextBox Text9 
  36.       Height          =   285
  37.       Left            =   2880
  38.       TabIndex        =   28
  39.       Text            =   "1000"
  40.       Top             =   4920
  41.       Width           =   855
  42.    End
  43.    Begin VB.TextBox Text7 
  44.       Height          =   285
  45.       Left            =   3840
  46.       TabIndex        =   20
  47.       Text            =   "-sin(x)/2"
  48.       Top             =   480
  49.       Width           =   3015
  50.    End
  51.    Begin VB.TextBox Text6 
  52.       Height          =   285
  53.       Left            =   720
  54.       TabIndex        =   19
  55.       Text            =   "(result)"
  56.       Top             =   4200
  57.       Width           =   2895
  58.    End
  59.    Begin VB.CommandButton btnPlot 
  60.       Caption         =   "Plot"
  61.       Height          =   375
  62.       Left            =   6960
  63.       TabIndex        =   13
  64.       Top             =   480
  65.       Width           =   615
  66.    End
  67.    Begin VB.PictureBox Picture1 
  68.       Height          =   1215
  69.       Left            =   3840
  70.       ScaleHeight     =   1155
  71.       ScaleWidth      =   2955
  72.       TabIndex        =   12
  73.       Top             =   840
  74.       Width           =   3015
  75.    End
  76.    Begin VB.CommandButton btnCalc 
  77.       Caption         =   "Calculate"
  78.       Height          =   375
  79.       Left            =   3720
  80.       TabIndex        =   9
  81.       Top             =   3720
  82.       Width           =   1335
  83.    End
  84.    Begin VB.TextBox Text5 
  85.       Height          =   285
  86.       Left            =   720
  87.       TabIndex        =   8
  88.       Text            =   "test*area(3.5,10)+1234"
  89.       Top             =   3720
  90.       Width           =   2895
  91.    End
  92.    Begin VB.CommandButton btnFunction 
  93.       Caption         =   "Define Function"
  94.       Height          =   375
  95.       Left            =   3720
  96.       TabIndex        =   7
  97.       Top             =   3240
  98.       Width           =   1335
  99.    End
  100.    Begin VB.CommandButton btnVariable 
  101.       Caption         =   "Define Variable"
  102.       Height          =   375
  103.       Left            =   3720
  104.       TabIndex        =   6
  105.       Top             =   2760
  106.       Width           =   1335
  107.    End
  108.    Begin VB.TextBox Text4 
  109.       Height          =   285
  110.       Left            =   720
  111.       TabIndex        =   5
  112.       Text            =   "area(length,width)=length*width"
  113.       Top             =   3240
  114.       Width           =   2895
  115.    End
  116.    Begin VB.TextBox Text3 
  117.       Height          =   285
  118.       Left            =   720
  119.       TabIndex        =   4
  120.       Text            =   "test=100"
  121.       Top             =   2760
  122.       Width           =   2895
  123.    End
  124.    Begin VB.CommandButton btnEval 
  125.       Caption         =   "Calculate"
  126.       Height          =   375
  127.       Left            =   120
  128.       TabIndex        =   3
  129.       Top             =   1320
  130.       Width           =   1095
  131.    End
  132.    Begin VB.TextBox Text2 
  133.       Height          =   285
  134.       Left            =   720
  135.       TabIndex        =   1
  136.       Text            =   "(result)"
  137.       ToolTipText     =   "Text2 = ucEval(Text1)"
  138.       Top             =   840
  139.       Width           =   2655
  140.    End
  141.    Begin VB.TextBox Text1 
  142.       Height          =   285
  143.       Left            =   720
  144.       TabIndex        =   0
  145.       Text            =   "3+4/5-8"
  146.       Top             =   480
  147.       Width           =   2655
  148.    End
  149.    Begin VB.Label Label16 
  150.       Alignment       =   2  'Center
  151.       BackColor       =   &H00FFFFC0&
  152.       BorderStyle     =   1  'Fixed Single
  153.       Caption         =   "Speed Test"
  154.       BeginProperty Font 
  155.          Name            =   "MS Sans Serif"
  156.          Size            =   9.75
  157.          Charset         =   0
  158.          Weight          =   700
  159.          Underline       =   0   'False
  160.          Italic          =   0   'False
  161.          Strikethrough   =   0   'False
  162.       EndProperty
  163.       Height          =   375
  164.       Left            =   120
  165.       TabIndex        =   35
  166.       Top             =   4800
  167.       Width           =   1695
  168.    End
  169.    Begin VB.Label Label19 
  170.       Caption         =   "Elapsed (sec) / Answer:"
  171.       Height          =   255
  172.       Left            =   3960
  173.       TabIndex        =   33
  174.       Top             =   4920
  175.       Width           =   1695
  176.    End
  177.    Begin VB.Label Label18 
  178.       Caption         =   "User Expression:"
  179.       Height          =   255
  180.       Left            =   4440
  181.       TabIndex        =   32
  182.       Top             =   4560
  183.       Width           =   1215
  184.    End
  185.    Begin VB.Line Line17 
  186.       BorderWidth     =   2
  187.       X1              =   120
  188.       X2              =   3720
  189.       Y1              =   4680
  190.       Y2              =   4680
  191.    End
  192.    Begin VB.Label Label17 
  193.       Caption         =   "Summation from 1 to:"
  194.       Height          =   375
  195.       Left            =   2040
  196.       TabIndex        =   29
  197.       Top             =   4800
  198.       Width           =   855
  199.    End
  200.    Begin VB.Line Line16 
  201.       BorderWidth     =   2
  202.       X1              =   3720
  203.       X2              =   3720
  204.       Y1              =   4680
  205.       Y2              =   4320
  206.    End
  207.    Begin VB.Line Line14 
  208.       BorderWidth     =   2
  209.       X1              =   3720
  210.       X2              =   7680
  211.       Y1              =   4320
  212.       Y2              =   4320
  213.    End
  214.    Begin VB.Label Label15 
  215.       Caption         =   "Text6:"
  216.       Height          =   255
  217.       Left            =   120
  218.       TabIndex        =   27
  219.       Top             =   4200
  220.       Width           =   495
  221.    End
  222.    Begin VB.Label Label14 
  223.       Caption         =   "Text5:"
  224.       Height          =   255
  225.       Left            =   120
  226.       TabIndex        =   26
  227.       Top             =   3720
  228.       Width           =   495
  229.    End
  230.    Begin VB.Label Label13 
  231.       Caption         =   "Text4:"
  232.       Height          =   255
  233.       Left            =   120
  234.       TabIndex        =   25
  235.       Top             =   3240
  236.       Width           =   495
  237.    End
  238.    Begin VB.Label Label12 
  239.       Caption         =   "Text3:"
  240.       Height          =   255
  241.       Left            =   120
  242.       TabIndex        =   24
  243.       Top             =   2760
  244.       Width           =   495
  245.    End
  246.    Begin VB.Line Line13 
  247.       X1              =   5280
  248.       X2              =   5640
  249.       Y1              =   3960
  250.       Y2              =   3960
  251.    End
  252.    Begin VB.Line Line12 
  253.       X1              =   5640
  254.       X2              =   5520
  255.       Y1              =   3960
  256.       Y2              =   3840
  257.    End
  258.    Begin VB.Line Line11 
  259.       X1              =   5640
  260.       X2              =   5520
  261.       Y1              =   3960
  262.       Y2              =   4080
  263.    End
  264.    Begin VB.Line Line10 
  265.       X1              =   5280
  266.       X2              =   5640
  267.       Y1              =   3480
  268.       Y2              =   3480
  269.    End
  270.    Begin VB.Line Line9 
  271.       X1              =   5640
  272.       X2              =   5520
  273.       Y1              =   3480
  274.       Y2              =   3360
  275.    End
  276.    Begin VB.Line Line8 
  277.       X1              =   5640
  278.       X2              =   5520
  279.       Y1              =   3480
  280.       Y2              =   3600
  281.    End
  282.    Begin VB.Line Line7 
  283.       X1              =   5280
  284.       X2              =   5640
  285.       Y1              =   3000
  286.       Y2              =   3000
  287.    End
  288.    Begin VB.Line Line6 
  289.       X1              =   5640
  290.       X2              =   5520
  291.       Y1              =   3000
  292.       Y2              =   2880
  293.    End
  294.    Begin VB.Line Line5 
  295.       X1              =   5640
  296.       X2              =   5520
  297.       Y1              =   3000
  298.       Y2              =   3120
  299.    End
  300.    Begin VB.Label Label11 
  301.       Caption         =   "Text6 = ucEval(Text5)"
  302.       Height          =   255
  303.       Left            =   5880
  304.       TabIndex        =   23
  305.       Top             =   3840
  306.       Width           =   1695
  307.    End
  308.    Begin VB.Label Label10 
  309.       Caption         =   "Source Code:"
  310.       BeginProperty Font 
  311.          Name            =   "MS Sans Serif"
  312.          Size            =   8.25
  313.          Charset         =   0
  314.          Weight          =   400
  315.          Underline       =   -1  'True
  316.          Italic          =   0   'False
  317.          Strikethrough   =   0   'False
  318.       EndProperty
  319.       Height          =   255
  320.       Left            =   5880
  321.       TabIndex        =   22
  322.       Top             =   2400
  323.       Width           =   1575
  324.    End
  325.    Begin VB.Label Label3 
  326.       Caption         =   "Source Code:"
  327.       BeginProperty Font 
  328.          Name            =   "MS Sans Serif"
  329.          Size            =   8.25
  330.          Charset         =   0
  331.          Weight          =   400
  332.          Underline       =   -1  'True
  333.          Italic          =   0   'False
  334.          Strikethrough   =   0   'False
  335.       EndProperty
  336.       Height          =   255
  337.       Left            =   1680
  338.       TabIndex        =   21
  339.       Top             =   1440
  340.       Width           =   1575
  341.    End
  342.    Begin VB.Line Line15 
  343.       BorderWidth     =   2
  344.       X1              =   7680
  345.       X2              =   120
  346.       Y1              =   2280
  347.       Y2              =   2280
  348.    End
  349.    Begin VB.Line Line1 
  350.       BorderWidth     =   2
  351.       X1              =   3600
  352.       X2              =   3600
  353.       Y1              =   120
  354.       Y2              =   2280
  355.    End
  356.    Begin VB.Line Line4 
  357.       X1              =   1560
  358.       X2              =   1440
  359.       Y1              =   1560
  360.       Y2              =   1680
  361.    End
  362.    Begin VB.Line Line3 
  363.       X1              =   1560
  364.       X2              =   1440
  365.       Y1              =   1560
  366.       Y2              =   1440
  367.    End
  368.    Begin VB.Line Line2 
  369.       X1              =   1320
  370.       X2              =   1560
  371.       Y1              =   1560
  372.       Y2              =   1560
  373.    End
  374.    Begin VB.Label Label9 
  375.       Caption         =   "ucDefineFunction Tex4"
  376.       Height          =   255
  377.       Left            =   5880
  378.       TabIndex        =   18
  379.       Top             =   3360
  380.       Width           =   1695
  381.    End
  382.    Begin VB.Label Label8 
  383.       Caption         =   "ucDefineVariable Text3"
  384.       Height          =   255
  385.       Left            =   5880
  386.       TabIndex        =   17
  387.       Top             =   2880
  388.       Width           =   1695
  389.    End
  390.    Begin VB.Label Label7 
  391.       Caption         =   "Text2:"
  392.       Height          =   255
  393.       Left            =   120
  394.       TabIndex        =   16
  395.       Top             =   840
  396.       Width           =   495
  397.    End
  398.    Begin VB.Label Label6 
  399.       Caption         =   "Text1:"
  400.       Height          =   255
  401.       Left            =   120
  402.       TabIndex        =   15
  403.       Top             =   480
  404.       Width           =   615
  405.    End
  406.    Begin VB.Label Label5 
  407.       Caption         =   "Text2 = ucEval(Text1)"
  408.       Height          =   255
  409.       Left            =   1680
  410.       TabIndex        =   14
  411.       Top             =   1680
  412.       Width           =   1695
  413.    End
  414.    Begin VB.Label Label4 
  415.       Caption         =   "Example usng ucEvaluate() in a time-critical loop"
  416.       BeginProperty Font 
  417.          Name            =   "MS Sans Serif"
  418.          Size            =   8.25
  419.          Charset         =   0
  420.          Weight          =   400
  421.          Underline       =   -1  'True
  422.          Italic          =   0   'False
  423.          Strikethrough   =   0   'False
  424.       EndProperty
  425.       Height          =   255
  426.       Left            =   3840
  427.       TabIndex        =   11
  428.       Top             =   120
  429.       Width           =   3495
  430.    End
  431.    Begin VB.Label Label2 
  432.       Caption         =   "Example with a user-defined variable and function"
  433.       BeginProperty Font 
  434.          Name            =   "MS Sans Serif"
  435.          Size            =   8.25
  436.          Charset         =   0
  437.          Weight          =   400
  438.          Underline       =   -1  'True
  439.          Italic          =   0   'False
  440.          Strikethrough   =   0   'False
  441.       EndProperty
  442.       Height          =   255
  443.       Left            =   720
  444.       TabIndex        =   10
  445.       Top             =   2400
  446.       Width           =   3735
  447.    End
  448.    Begin VB.Label Label1 
  449.       Caption         =   "Example using ucEval() for simplicity"
  450.       BeginProperty Font 
  451.          Name            =   "MS Sans Serif"
  452.          Size            =   8.25
  453.          Charset         =   0
  454.          Weight          =   400
  455.          Underline       =   -1  'True
  456.          Italic          =   0   'False
  457.          Strikethrough   =   0   'False
  458.       EndProperty
  459.       Height          =   255
  460.       Left            =   720
  461.       TabIndex        =   2
  462.       Top             =   120
  463.       Width           =   2655
  464.    End
  465. Attribute VB_Name = "Form1"
  466. Attribute VB_GlobalNameSpace = False
  467. Attribute VB_Creatable = False
  468. Attribute VB_PredeclaredId = True
  469. Attribute VB_Exposed = False
  470. Private Sub Form_Load()
  471.     ucalcNull = ucEval("Display opening messages")
  472. End Sub
  473. ' Demonstrates the use of ucEval()
  474. ' Your program should include an error handler
  475. Private Sub btnEval_Click()
  476.     On Error GoTo ErrorHandler
  477.     Text2 = ucEval(Text1)
  478. If ucError = 0 Then Exit Sub
  479. ErrorHandler:
  480.     If Err Then MsgBox Error$, vbExclamation
  481.     If ucError Then MsgBox ucErrorMessage, vbExclamation
  482. End Sub
  483. ' Demonstrates the fast ucEvaluate() function
  484. Private Sub btnPlot_Click()
  485.     Dim x As Double, UserEq As Long, VariableX As Long
  486.     On Error Resume Next
  487.     Picture1.Cls
  488.     Picture1.Scale (-10, 2)-(10, -2)
  489.     Picture1.PSet (-10, 0)
  490.     VariableX = ucDefineVariable("x")
  491.     UserEq = ucParse(Text7)
  492.     For x = -10 To 10 Step 0.5
  493.         ucVariableValue(VariableX) = x
  494.         Picture1.Line -(x, ucEvaluate(UserEq))
  495.     Next
  496.     ucReleaseExpr
  497. End Sub
  498. ' Defines a function at runtime
  499. Private Sub btnFunction_Click()
  500.     ' On Error Goto ...
  501.     ucDefineFunction Text4
  502. End Sub
  503. ' Defines a variable at runtime
  504. Private Sub btnVariable_Click()
  505.     ' On Error GoTo ...
  506.     ucDefineVariable Text3
  507. End Sub
  508. ' Example using the one-step ucEval() function
  509. ' Your program should include an error handler
  510. Private Sub btnCalc_Click()
  511.     On Error GoTo ErrorHandler
  512.     Text6 = ucEval(Text5)
  513. If ucError = 0 Then Exit Sub
  514. ErrorHandler:
  515.     If Err Then MsgBox Error$, vbExclamation
  516.     If ucError Then MsgBox ucErrorMessage, vbExclamation
  517. End Sub
  518. Private Sub Command1_Click()
  519.     Dim x As Double, UserEq As Long, VarX As Integer
  520.     Dim Sum As Double, TimerStart As Single, Elapsed As Single
  521.     Text10 = ""
  522.     Text10.Refresh
  523.     TimerStart = Timer
  524.     VarX = ucDefineVariable("x")
  525.     UserEq = ucParse(Text8)
  526.     For x = 1 To Text9
  527.         ucVariableValue(VarX) = x
  528.         Sum = Sum + ucEvaluate(UserEq)
  529.     Next
  530.     Elapsed = Timer - TimerStart
  531.     Text10 = Int(Elapsed * 100) / 100 & " / " & Sum
  532.     ucReleaseExpr
  533. End Sub
  534.